package com.qd.hik.dto.charge;

import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * 〈一句话功能简述〉<br>
 *
 * @author sjk
 * @create 2024-05-30 11:56
 * @since 1.0.0
 */
@Data
@Accessors(chain = true)
public class HkParkOrdersResp {
    /**
     *
     */
    private List<Results> results;
    /**
     * 总页码
     */
    private Integer totalPage;
    /**
     * 当前页码
     */
    private Integer pageNo;

    public void freeData() {
        this.totalPage = null;
        this.pageNo = null;
        if (this.results != null) {
            this.results.forEach(Results::freeData);
        }
    }

    @Data
    @Accessors(chain = true)
    public static class Results {
        /**
         * 停车场编号
         */
        private String parkCode;
        /**
         * 待支付帐单id，用于批量下单
         */
        private String arrearsId;
        /**
         * 支付能力,requestType=2下发
         */
        private List<PayCapacities> payCapacities;
        /**
         * 停车场名称
         */
        private String parkName;
        /**
         * 订单标识
         */
        private String uniqueId;
        /**
         * 停车开始时间 2021/01/01 12:00:00
         */
        private String parkStartTime;
        /**
         * 停车时长，单位分钟
         */
        private String parkTime;
        /**
         * 停车时长，如：2小时10分钟
         */
        private String parkTimeText;
        /**
         * 车牌号码格式化
         */
        private String formatPlateNo;
        /**
         * 车牌号码
         */
        private String plateNo;
        /**
         * 剩余待支付金额，单位分
         */
        private String shouldPayLeft;
        /**
         * 订单总额，单位分
         */
        private String shouldPayTotal;
        /**
         * 停车状态 1-正在停车 2-已出场
         */
        private String parkState;

        public String getPlateNo() {
            if(StringUtils.hasLength(formatPlateNo)){
                plateNo = formatPlateNo.replace("·","");
            }
            return plateNo;
        }

        public void freeData() {
            this.parkCode = null;
            this.arrearsId = null;
            if (null != this.payCapacities) {
                this.payCapacities.forEach(PayCapacities::freeData);
            }
            this.parkName = null;
            this.uniqueId = null;
            this.parkStartTime = null;
            this.parkTime = null;
            this.parkTimeText = null;
            this.formatPlateNo = null;
            this.plateNo = null;
            this.shouldPayLeft = null;
            this.shouldPayTotal = null;
            this.parkState = null;
        }
    }

    @Data
    @Accessors(chain = true)
    public static class PayCapacities {
        /**
         * 支付参数唯一Id
         */
        private String payId;
        /**
         * 支付方式
         */
        private String payType;

        public void freeData() {
            payId = null;
            payType = null;
        }
    }
}